#project origin directory
set origin_dir "."
#project name
set _xil_proj_name_ "ddr4_ctrl_proj"
#create project
create_project ${_xil_proj_name_} ./${_xil_proj_name_} -part xczu4ev-sfvc784-2-i -force

# =========================================================
#point to the rtl source document and create  sources_1 directory to store the new 
#source files that currently created

#判断sources_1 和 “”（空字符串）是否相等，如果相等，也就是还没有创建sources_1,那么就创建sources_1
if {[string equal [get_filesets -quiet sources_1] ""]} {
  create_fileset -srcset sources_1
}
#用obj表示sources_1的文件集
set obj [get_filesets sources_1]
#用files表示 rtl文件夹中的源码文件集
set files [list \
 [file normalize "${origin_dir}/../rtl/top.sv"]\
 [file normalize "${origin_dir}/../rtl/axi_rmst_bridge.v"]\
 [file normalize "${origin_dir}/../rtl/axi_wmst_bridge.v"]\
 [file normalize "${origin_dir}/../rtl/ddr4_user.sv"]\
 [file normalize "${origin_dir}/../rtl/ddr4_reader.sv"]\
 [file normalize "${origin_dir}/../rtl/ddr4_writer.sv"]\
 
 
]
#add_files 将files引用到sources_1,不拷贝
set added_files [add_files -fileset sources_1 $files]
set_property -name "top" -value "top" -objects $obj
set_property -name "top_auto_set" -value "0" -objects $obj

#bd tcl，直接执行即可
source ${origin_dir}/../bd/ddr4.tcl


#ip are copied from the ip directory, remember to update if changed in proj
#set files [list \
# [file normalize "${origin_dir}/../../ip/2020.2/xcku3p-ffvb676-2-i/adc1_jesd204_phy/adc1_jesd204_phy.xci"]\
#
#]
#
# #import_files 将file的文件集拷贝到sources_1，与add_files不一样
#set imported_files [import_files -fileset sources_1 $files]

# add the constrs files
if {[string equal [get_filesets -quiet constrs_1] ""]} {
  create_fileset -srcset constrs_1
}

set obj [get_filesets constrs_1]
set files [list \
 [file normalize "${origin_dir}/pin.xdc"]\
 [file normalize "${origin_dir}/timing.xdc"]\
]
set added_files [add_files -fileset constrs_1 $files]

# add simulation files

#if {[string equal [get_filesets -quiet sim_1] ""]} {
#  create_fileset -srcset sim_1
#}
#set obj [get_filesets sim_1]
#set files [list \
# [file normalize "${origin_dir}/../../sim/d0_board/aom_ctrl_top_tb.sv"]\
#
#]
#set added_files [add_files -fileset sim_1 $files]
#set_property -name "top" -value "data_path_tb" -objects $obj
#set_property -name "top_auto_set" -value "0" -objects $obj
#set_property verilog_define SIM [get_filesets sim_1]


